package com.fan.gofast.util;

import org.apache.commons.codec.binary.Hex;

import java.security.MessageDigest;

public class EncryptionUtil {

    public static String sha256(String str) {
        MessageDigest messageDigest = null;
        String enencdeStr = "";
        try {
            messageDigest = MessageDigest.getInstance("SHA-256");
            byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
            enencdeStr = Hex.encodeHexString(hash);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return enencdeStr;
    }
}
